<?php
/**
 * Created by PhpStorm.
 * User: sunfan
 * Date: 2017/3/22
 * Time: 11:50
 */

namespace Admin\Model;

use Think\Model;

class BusinessRangeModel extends Model
{

    /* 自动验证规则 */
    protected $_validate = array(
        array('area_name', 'require', '商圈名称不能为空' ),
        array('region','require','区域名称必填'),
        array('road','require','街道名称必填'),
        array('place','require','商圈名称必填'),
    );

    public function store($data){
        if($this->create()){
            $add =  $this->add($data);
            if($add){
                return true;
            }else{
                $this->error="添加出错，请稍后再试！";
            }
        }
        return false;
    }

    public function update($data){
        if($this->create()){
            $id = $data['id'];
            unset($data['id']);
            $add =  $this->where('id='.$id)->save($data);
            if($add){
                return true;
            }else{
                $this->error="添加出错，请稍后再试！";
            }
        }
        return false;
    }

}